import { ActionType, EditableFormInstance, EditableProTable, ProCard, ProColumns, ProForm, ProFormDatePicker, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText, ProTable } from "@ant-design/pro-components";
import { Button, Col, Image, message, Modal, Row, Space } from "antd";
import { useEffect, useRef, useState } from "react";
import { getSelection } from "@/services/selections";
import QueryMaterial2 from "@/components/QueryMaterial2";
import moment from "moment";
import QueryUserDefine from "@/components/QueryUserDefine";
import { s_getSaleInfo, s_getTableInfo, s_getTableInfoDetail, s_operateInfo, s_produce_updateInfo, s_updateInfo, state2text, status2text } from "@/services/basis";
import Addition from "@/components/Addition";
import ImportData from "@/components/ImportData";
import { useModel } from "@umijs/max";

const App:React.FC=()=>{
    const [etype,setEtype]=useState(1);
    const [open,setOpen]=useState(false);
    const [selectedRecord,setSelectedRecord]=useState<DataType[]>([]);
    const [selectDetail,setSelectedDetail]=useState<any[]>([]);
    const [material,setMaterial]=useState([]);
    const [dataSource,setDataSource]=useState<any[]>([]);
    const [userdefine,setUserDefine]=useState<{uid:any,uname:any,vlabel:any,value:any}[]>([]);
    const [rowno,setRowno]=useState(0); 
    const [addition,setAddition]=useState([]);
    const [vouchCode,setVouchCode]=useState(null);

    const mform_ref=useRef<ProFormInstance>();
    const mtable_ref=useRef<ActionType>();
    const mtable2_ref=useRef<ActionType>();
    const editorFormRef=useRef<EditableFormInstance>();
    const [total,setTotal]=useState(0);

    const { initialState, setInitialState } = useModel('@@initialState');
    // initialState?.currentUser?.userid
    const [selectedLineKeys,setSelectedLineKeys]=useState<any[]>([]);

    useEffect(()=>{
        // if(userdefine.length>0){
          // alert(JSON.stringify(userdefine));
        const u=userdefine;
        var u1:any[]=[];
        var u2:any[]=[];
        u.map((item:any)=>{
          u1.push({uid:item.uid,value:item.value});
          u2.push(''.concat(item.uname,':',item.vlabel==''?item.value:item.vlabel));
        });
    
        // alert(JSON.stringify(u1));
        editorFormRef.current?.setRowData?.(rowno.toString(),{
          userdefine_id:JSON.stringify(u1) ,
          userdefine_name:u2.toString(),
        });
         
      // }
      },[userdefine]);

    //当组件选择物料时，更新表格并重载--
            useEffect(()=>{
               if(material.length>0){
               var x:any[]=editorFormRef.current?.getRowsData?.();
               // alert(JSON.stringify(x));
               if(x==undefined)
                  x=[];
               material.map((item:any)=>{
                  x?.push({rid:Math.random().toFixed(10),
                          //  id:Math.random().toFixed(10).toString(),
                            material_id:item.id,material_code:item.code,material_name:item.name,
                            invstd:item.invstd,invstd2:item.invstd2,munit_name:item.munit_name,  
                            hassample:0,deliverdate:moment().format('YYYY-MM-DD'),quantity:1, dosample:0,
                            userdefine_id:'[]',vendor_id:'[]',pic:item.pic,
                  });
               });
               // alert(JSON.stringify(x));
               setDataSource(x);
                
               mform_ref.current?.setFieldValue('editable',x);
               mtable2_ref.current?.reloadAndRest?.();
            }
            },[material]);

            // 全部开始编辑，置表格为编辑状态
              function quote(){
                //用一个循环
                const x:any[]=editorFormRef.current?.getRowsData?.();
                if(x!=undefined&&x.length>0)
                  x.map((item:any,index)=>{
                      mtable2_ref.current?.startEditable?.(index);
                   }
                );
                else
                  message.warning('没有任何修改');
              }

    interface DataType{
        // mid,id,x_id,org_id,custom_id,operate_time,operater_id,saletype_id,
        // code,state,status,memo,source_type,source_id,addition,business_id,
		// 		material_id,userdefine,userdefine2,quantity,price,taxrate,total,netprice,nettotal,
		// 		source_type2,source_id2,state2,status2,memo2,deliverdate2,
		// 		material_addition,material_code,material_name,scode,invstd,invstd2,
		// 		brand,munit_name,custom_name,org_name,operater_name,business_name,saletype_name
        mid?:number,id?:number,x_id?:number,org_id?:number,custom_id?:number,operate_time?:string,
        operater_id?:number,saletype_id?:number,code?:string,state?:number,status?:number,
        memo?:string,source_type?:string,source_id?:number,addition?:string,business_id?:number,
		material_id?:number,userdefine_id?:string,userdefine_name?:string,quantity?:number,taxrate?:number,
        total?:number,netprice?:number,nettotal?:number,source_type2?:string,source_id2?:number,
        state2?:number,status2?:number,memo2?:string,deliverdate2?:string,material_addition?:string,
        material_code?:string,material_name?:string,scode?:string,invstd?:string,invstd2?:string,
		brand?:string,munit_name?:string,custom_name?:string,org_name?:string,operater_name?:string,
        business_name?:string,saletype_name?:string,deliverdate?:string,
    }

    const columns:ProColumns<DataType>[]=[
        {dataIndex:'id',title:'ID',hidden:true},{dataIndex:'custom_name',title:'店铺', },
        {dataIndex:'business_name',title:'业务员', },
        {dataIndex:'code',title:'单据编码', },
        {dataIndex:'deliverdate',title:'需求日期',valueType:'date',search:false},
        // {dataIndex:'deliverdate',title:'交货日期'},
        {dataIndex:'memo',title:'备注',search:false, },
        {dataIndex:'operater_name',title:'制单人',search:false, },
        {dataIndex:'operate_time',title:'制单时间',valueType:'date', },
        // {dataIndex:'source_type',title:'采购申报单来源',search:false,width:100},
        // {dataIndex:'state',title:'进度',
        //   render:(text:any)=>state2text(1,text),
        // },
        {dataIndex:'status',title:'状态',valueType:'select',width:80,
            valueEnum:{1:{text:'未审核'},5:{text:'已审核'},
            6:{text:'已弃审'},2:{text:'关闭'},3:{text:'删除'},9:{text:'全部'}}
        }, 
    ];

    interface DataType2{
        rid?:number,id:number,material_id?:number,material_code?:string,material_name?:string,
        invstd?:string,invstd2?:string,userdefine_id?:string,userdefine_name?:string,munit_name?:string,
        quantity?:number,taxrate?:number,total?:number,netprice?:number,nettotal?:number,price:number,
        deliverdate2?:string,state2?:number,status2?:number,memo2?:string,material_addition?:string,
        pic?:string,
    }

    const columns2:ProColumns<DataType2>[]=[
        {dataIndex:'rid',title:'RID',editable:false,hidden:true,},
        {dataIndex:'id',title:'ID',editable:false,hidden:true,},
        {dataIndex:'material_id',title:'物料ID',editable:false,hidden:true,},
        {dataIndex:'pic',title:'图片' ,editable:false,width:80,
          //  render:(text)=>{
          //      var pic=text=="-"||text==undefined?"":"/basis_api/file/get?filename="+text;
          //      return <Image src={pic}  
          //             style={{width:50,height:50}} alt='无' />
           render:(text,record,index,k)=>{
                       var pic="/basis_api/file/get2?filename="+record.material_code;
                       return   <Image src={pic}  style={{width:50,height:50}} alt='无' />
          },
        },
        {dataIndex:'material_code',title:'SKU编码',editable:false,},
        {dataIndex:'material_name',title:'名称',editable:false,},
        {dataIndex:'invstd',title:'包装规格',editable:false,},
        {dataIndex:'invstd2',title:'型号',editable:false,},
        // {dataIndex:'userdefine_id',title:'自定义ID',editable:false,hidden:true,},
        // {dataIndex:'userdefine_name',title:'自定义值',editable:false,},
        // {title:'属性',editable:false,
        //     render:(text,record)=><QueryUserDefine setData={setUserDefine} 
        //                   objtype={1} dotype={1} id={record.material_id} setRowno={setRowno} rowno={record.rid} />
        //    },
        {dataIndex:'munit_name',title:'计量单位',editable:false,},
        {dataIndex:'quantity',title:'数量',valueType:'digit',
          fieldProps:(_,{rowIndex})=>{
                return {
                   onChange:()=>{
                      // alert(rowIndex);
                      const rowdata=editorFormRef?.current?.getRowData?.(rowIndex);
                      // alert(JSON.stringify(rowdata));
                      const quantity=rowdata?.quantity==null?0:rowdata?.quantity;
                      const price=rowdata?.price==null?0:rowdata?.price;
                      const taxrate=rowdata?.taxrate==null?0:rowdata?.taxrate;
                      editorFormRef.current?.setRowData?.(rowIndex,
                          {total:quantity*price,
                           netprice:price/(1+taxrate/100),
                           nettotal:(price/(1+taxrate/100))*quantity,
                         });
                   },
                }
             }
        },
      //   {dataIndex:'price',title:'含税单价',valueType:'digit',
      //      fieldProps:(_,{rowIndex})=>{
      //           return {
      //              onChange:()=>{
      //                 // alert(rowIndex);
      //                 const rowdata=editorFormRef?.current?.getRowData?.(rowIndex);
      //                 // alert(JSON.stringify(rowdata));
      //                 const quantity=rowdata?.quantity==null?0:rowdata?.quantity;
      //                 const price=rowdata?.price==null?0:rowdata?.price;
      //                 const taxrate=rowdata?.taxrate==null?0:rowdata?.taxrate;
      //                 editorFormRef.current?.setRowData?.(rowIndex,
      //                    {total:quantity*price,
      //                      netprice:price/(1+taxrate/100),
      //                      nettotal:(price/(1+taxrate/100))*quantity,
      //                    });
      //              },
      //           }
      //        }
      //   },
      //   {dataIndex:'taxrate',title:'税率%',valueType:'digit',
      //       fieldProps:(_,{rowIndex})=>{
      //          return {
      //         onChange:()=>{
      //       // alert(rowIndex);
      //       const rowdata=editorFormRef?.current?.getRowData?.(rowIndex);
      //       // alert(JSON.stringify(rowdata));
      //       const quantity=rowdata?.quantity==null?0:rowdata?.quantity;
      //       const price=rowdata?.price==null?0:rowdata?.price;
      //       const taxrate=rowdata?.taxrate==null?0:rowdata?.taxrate;
      //       editorFormRef.current?.setRowData?.(rowIndex,
      //           {total:quantity*price,
      //            netprice:price/(1+taxrate/100),
      //            nettotal:(price/(1+taxrate/100))*quantity,
      //          });
      //    },
      // }
      //  }
      //   },
      //   {dataIndex:'total',title:'价税合计',editable:false},
      //   {dataIndex:'netprice',title:'不含税单价',editable:false,hidden:true,},
      //   {dataIndex:'nettotal',title:'不含税金额',editable:false,hidden:true},
        // {dataIndex:'deliverdate',title:'需求日期',valueType:'date',width:200},
        {dataIndex:'state2',title:'进度',editable:false,hidden:true},
        {dataIndex:'status2',title:'状态',editable:false,hidden:true,},
        {dataIndex:'memo',title:'备注',ellipsis:true,width:200},
        {dataIndex:'material_addition',title:'物料附件',editable:false,hidden:true,},
        {
            title:'操作',            
            fixed:'right',
            valueType:'option',
            width:80,
            editable:false,
            render:(text,record,_,action)=>[
              //  <a key='edit2'
              //     onClick={()=>{
              //         alert(record.rid);
              //        action?.startEditable?.(record.rid);}}
              //  >
              //      编辑
              //  </a>,
               <a  key='del2'
                   onClick={()=>{
                     var x:any[]=[];
                     x=editorFormRef.current?.getRowsData?.();
                     //  alert(JSON.stringify(x));
                     setDataSource(x.filter((item)=>item.id!=record.id));
                     // alert(JSON.stringify(x.filter((item)=>item.id!=record.id)));
                     // mtable2_ref.current?.reloadAndRest?.();
                     mform_ref.current?.setFieldValue('editable',x.filter((item)=>item.rid!=record.rid));
                   }}
               >
                   删除
               </a>,
            ]
         }
    ];

    // 新增采购申报单
    async function add(){
        setEtype(1);
        setVouchCode(null);
        setOpen(true);
    }

    // 编辑采购申报单
    async function edit(){
      if(selectedRecord.length==0)
         message.warning('请选择要编辑的行');
      else if(selectedRecord[0].status==2||selectedRecord[0].status==3||selectedRecord[0].status==5)
         message.warning('不能编辑已审核、已关闭、已删除的单据。请先弃审或恢复。');
      else{
        const id=selectedRecord[0].id;
        const x=await s_getTableInfoDetail({source:'v_sale_order_detail2',x_id:0,mid:id});
        setSelectedDetail( x.data );
        setEtype(0);
        //通过useState初始化无效，只能强制设置值-----多了一层对象包裹，无法直接设置。所以拆分来设就好
        // mform_ref.current?.setFieldsValue({...selectedRecord[0],
        //   editable:x.data});
        // alert(JSON.stringify({...selectedRecord[0],
        //   editable:x.data}));
        // setVouchCode(selectedRecord[0].code);
        setOpen(true);
      }
    } 

    //保存采购申报单
    async function save(){
        // mform_ref.current?.submit();
        const x=editorFormRef?.current?.getRowsData?.();
        x?.map((item,index)=>{
          mtable2_ref.current?.saveEditable?.(index);
        });
  
        // alert(JSON.stringify(x));
        // alert('CCC');
        var fdata2=mform_ref.current?.getFieldsValue();
        var t1=fdata2.editable;
                t1=t1.map((item:any)=>({
                      id:item.id,mid:item.mid, source_type:1,
                      material_id:item.material_id,userdefine_id:item.userdefine_id,
                      userdefine_name:item.userdefine_name,
                      deliverdate:moment(moment(fdata2.deliverdate).toDate()).format('YYYY-MM-DD'),
                      quantity:item.quantity,price:item.price,total:item.total,
                      taxrate:item.taxrate,netprice:item.netprice,nettotal:item.nettotal,
                      memo:item.memo,alloc_type:item.alloc_type
                   }));
        
        fdata2={code:fdata2.code,custom_id:fdata2.custom_id,id:fdata2.id,mid:fdata2.mid,
                         business_id:fdata2.business_id,org_id:fdata2.org_id,operater_id:fdata2.operater_id,
                         state:fdata2.state,status:fdata2.status,memo:fdata2.memo,
                        deliverdate:moment(moment(fdata2.deliverdate).toDate()).format('YYYY-MM-DD')};
        
        // const t2=t1.map((item:any)=>({...item,
        //                     deliverdate:moment(moment(item.deliverdate).toDate()).format('YYYY-MM-DD')}));
        const fdata={...fdata2,editable:t1,addition,vouch_type:1};

        // alert(JSON.stringify(t1));
        //  alert(JSON.stringify(fdata.editable[0]));
                // source,x_id,operater_id,etype,fdata
                const y=await s_updateInfo({x_id:1,source:'sale_order',
                       operater_id:initialState?.currentUser?.userid,etype,fdata});
          // alert('dddd');
          // alert(JSON.stringify(y));
          if(y.success){
                  message.success('保存成功');
                  // setEtype(1);
                  setSelectedRecord([]);
                  mtable_ref.current?.reloadAndRest?.();
                  // setOpen(false);
            }else
                  message.error('保存失败，请联系管理员');
        // setEtype(1);
        // setOpen(false);
    }

   //取消
    async function cancel(){
        setEtype(1);
        setVouchCode(null);
        
        setOpen(false);
    }

   //  操作询价单/冻结/删除/恢复
      async function operateInfo(n:number){
       // source,x_id,operater_id,otype,id
       if(selectedRecord.length==0)
          message.warning('请选择要操作的行');
       else{
           if(n==5||n==6){
              if(n==5&&selectedRecord[0].status==5)
                  message.warning('此单据已审核，请不要重复操作');
              else if(n==6&&selectedRecord[0].status!=5)
                  message.warning('此单据未审核，不能弃审');
              else{
                  var yy=await s_produce_updateInfo({source:'produce_order_byverify',x_id:1,
                              operater_id:initialState?.currentUser?.userid,etype:n==5?1:0,fdata:{id:selectedRecord[0].id}});  
                 if(yy.success){                      
                     var x=await s_operateInfo({x_id:1,source:'sale_order_main',
                                     operater_id:initialState?.currentUser?.userid,otype:n,id:selectedRecord[0].id});
                 if(x.success){
                      message.success('申报单审核成功');
                      mtable_ref.current?.reloadAndRest?.();
                     }
                  else
                    message.error('审核失败，请联系管理员');
               }
            else
                message.error(yy.err);  
              }     
            }else{
                 var x=await s_operateInfo({x_id:1,source:'sale_order_main',
                                     operater_id:initialState?.currentUser?.userid,otype:n,id:selectedRecord[0].id});
                if(x.success){
                    message.success('操作成功');
                    mtable_ref.current?.reloadAndRest?.();
                 }else
                    message.error('操作失败，请联系管理员');
              } ;
             
        // 当审核或弃审时，自动生成或删除对应的生产单据2025-06-04
        // source,x_id,operater_id,etype,fdata
         
      };
  };

  
        
     
     
//    主窗体程序=========================================================================================================
    return <>
       <ProCard title='采购申报管理' style={{height:'55vh',overflow:'auto'}}
           extra={<Space>
              <Button onClick={()=>add()}>新增</Button>
              <Button onClick={()=>edit()}>编辑</Button>
              <Button onClick={()=>operateInfo(5)}>审核</Button>
              <Button onClick={()=>operateInfo(6)}>弃审</Button>
              <Button onClick={()=>operateInfo(2)}>关闭</Button>
              <Button onClick={()=>operateInfo(3)}>删除</Button>
              <Button onClick={()=>operateInfo(1)}>恢复</Button>
              <ImportData  x_id={1} source='importdata' tdata={{data:'sale_order'}} operater_id={initialState?.currentUser?.userid}  />
           </Space>}
       >
          <ProTable<DataType>
              rowKey='id'
              actionRef={mtable_ref}
              search={{span:4}}
              columns={columns}
              options={false}
              // v_sale_order_main
              request={async (param)=>{
                    const x=await s_getSaleInfo({source:'v_sale_order_main',x_id:1,
                                  fdata:{id:0,param}});
                     setTotal(x.data[0][0].count);
                      return{
                            data:x.data[1],
                            success:true,
                          }
                       }}
             rowSelection={{
                        type:'radio',
                        selectedRowKeys:selectedLineKeys,
                        async onChange(selectedRowKeys, selectedRows, info) {
                            setSelectedRecord(selectedRows);
                            setSelectedLineKeys(selectedRowKeys);
                            if(selectedRows.length>0){
                                 const id=selectedRows[0].id;
                                 const x=await s_getTableInfoDetail({source:'v_sale_order_detail2',x_id:0,mid:id});
                                 setSelectedDetail( x.data );
                                //  alert(JSON.stringify(x.data));
                            };
                        },
                      }} 
       onRow={(record)=>{
            return {
              onClick:async ()=>{
                const k=record.id;
                // if(selectedKeys.includes(k) )
                //      setSelectedKeys(selectedKeys.filter(item=>item.id!=k));
                // else
                            setSelectedRecord([record]);
                            setSelectedLineKeys([k]);
                            if(k&&k>0){
                                 const id=k;
                                 const x=await s_getTableInfoDetail({source:'v_sale_order_detail2',x_id:0,mid:id});
                                 setSelectedDetail( x.data );
                                //  alert(JSON.stringify(x.data));
                            };
              },
            }
           }}
             scroll={{y:'50vh'}}
                    pagination={{
                    showQuickJumper:true,
                    showSizeChanger:true,
                    defaultPageSize:10,
                    defaultCurrent:1,
                    total,
                  }}
            />
            </ProCard>
            <ProCard style={{height:'25vh',overflow:'auto'}}>
            <ProTable<DataType2>
              options={false}
              rowKey='id'
              // actionRef={mtable_ref}
              search={false}
              columns={columns2}
              scroll={{y:'15vh' }}
              dataSource={selectDetail}
              // request={async ()=>{
              //           // alert(11);
              //           const x=await s_getTableInfo({source:'v_sale_order_main',x_id:1,id:0});
              //           // alert(JSON.stringify(x.data));
              //           return {
              //             data:x.data,
              //             success:true,
              //           }
              //         }}
              //         rowSelection={{
              //           type:'radio',
              //           async onChange(selectedRowKeys, selectedRows, info) {
              //               setSelectedRecord(selectedRows);
                           
              //           },
              //         }} 
            />
       </ProCard>
       {/* 新增/编辑窗体--------------------------------------------------------------------------------- */}
       <Modal closable destroyOnClose onCancel={()=>setOpen(false)} onClose={()=>setOpen(true)}
           open={open} onOk={()=>save()} width={'90%'} style={{top:10}}
           okButtonProps={{hidden:true}} cancelButtonProps={{hidden:true}}
        >
          <ProCard title={etype==1?'新增采购申报':'编辑采购申报'} style={{height:'90vh',overflow:'auto'}}
             extra={<Space>
                <QueryMaterial2 setData={setMaterial} type='checkbox' x_id={1}/>
                <Addition source_xid={1} setData={setAddition} type={2}
                            fdata={{source_table:'addition_sale_order_main',
                                  source_code:vouchCode,
                                  source_field:'addition',
                                  source_id:selectedRecord.length==0?0:selectedRecord[0].id,
                                  source_value:selectedRecord.length==0||selectedRecord[0].addition==null||selectedRecord[0].addition==''?[]:selectedRecord[0].addition}}
                         />
                <Button onClick={()=>quote()}>开始编辑</Button>
                <Button onClick={()=>mform_ref.current?.submit()}>保存</Button>
                <Button onClick={()=>cancel()}>取消</Button>
              </Space>}
            >
               
                {/* // mid,id,x_id,org_id,custom_id,operate_time,operater_id,saletype_id,
        // code,state,status,memo,source_type,source_id,addition,business_id,
		// 		material_id,userdefine,userdefine2,quantity,taxrate,total,netprice,nettotal,
		// 		source_type2,source_id2,state2,status2,memo2,deliverdate2,
		// 		material_addition,material_code,material_name,scode,invstd,invstd2,
		// 		brand,munit_name,custom_name,org_name,operater_name,business_name,saletype_name */}
        <ProForm submitter={false} layout="horizontal" labelCol={{offset:0,span:5}} 
              labelWrap labelAlign="left"  formRef={mform_ref}
              initialValues={
                   etype==1?{state:1,status:0,operater_id:initialState?.currentUser?.userid,
                             deliverdate:moment().add(30,'day')}
                   :{...selectedRecord[0],
                    editable:selectDetail,
                   }
              }
              onFinish={save}
              >
                
               <ProFormText name='id' hidden/><ProFormText name='mid' hidden/>
               <Row gutter={8}>
                   <Col span={8}>
                        <ProFormText name='code' label='采购申报单编号' width={300} 
                        fieldProps={{
                          onChange:(e:any)=>{
                           setVouchCode(e.target.value);
                           // mform_ref.current?.setFieldValue('addition',e.target.value);
                          }
                          }}
                        />
                        <ProFormSelect name='business_id' label='业务员' width={300}
                           fieldProps={{
                            showSearch:true,
                           }}
                           request={async ()=>{
                            var x:any=await getSelection({source: 'v_businesser', x_id: 1 });
                            var x2=x.data.map((item:any)=>({value:item.id,label:item.name}));
                            return x2;
                            }}
                        /> 
                        <ProFormSelect name='org_id' label='部门' width={300}
                            fieldProps={{
                                showSearch:true,
                            }}
                            request={async ()=>{
                                      var x:any=await getSelection({source: 'base_organization', x_id: 1 });
                                      var x2=x.data.map((item:any)=>({value:item.id,label:item.name}));
                                      return x2;
                                      }}
                        />
                   </Col>
               
                   <Col span={8}>
                        <ProFormSelect name='custom_id' label='店铺' width={300}
                           rules={[{required:true,message:'必填项，请准确填写'}]}
                           fieldProps={{
                            showSearch:true,
                           }}
                           request={async ()=>{
                            var x:any=await getSelection({source: 'v_custom', x_id: 1 });
                            var x2=x.data.map((item:any)=>({value:item.id,label:item.name}));
                            return x2;
                            }}
                        />
                        {/* <ProFormSelect name='state' label='进度' width={300}  disabled
                          //  rules={[{required:true,message:'此为必填项'}]}
                           options={[{value:1,label:'未下达'},{value:2,label:'已下达'},{value:3,label:'供方已确认'},{value:4,label:'供方已拒绝'},
                                    {value:5,label:'已确认'},{value:6,label:'已拒绝'},{value:7,label:'撤销确认'},{value:8,label:'供方撤销确认'},
                                    {value:9,label:'撤销下达'},{value:10,label:'未提交'},{value:11,label:'已提交'},{value:12,label:'撤销提交'},
                                    {value:13,label:'已核价'},{value:14,label:'撤销核价'}
                                   ]}
          /> */}
                        <ProFormSelect name='operater_id' label='制单人' width={300} disabled
                           fieldProps={{
                            showSearch:true,
                           }}
                           request={async ()=>{
                            var x:any=await getSelection({source: 'base_person', x_id: 1 });
                            var x2=x.data.map((item:any)=>({value:item.id,label:item.name}));
                            return x2;
                            }}
                        />
                       
                      <ProFormText name='memo' label='备注' width={800}   />
                
                   </Col>
              
                   <Col span={8}>
                    {/*     <ProFormSelect name='saletype_id' label='采购申报类型' width={300}
                           fieldProps={{
                            showSearch:true,
                           }}
                           request={async ()=>{
                            var x:any=await getSelection({source: 'base_saletype', x_id: 1 });
                            var x2=x.data.map((item:any)=>({value:item.id,label:item.name}));
                            return x2;
                            }}
                        />
                        <ProFormRadio.Group name='status' label='状态' width={300}  disabled
                              // rules={[{required:true,message:'此为必填项'}]}
                                options={[{value:0,label:'未审核'},{value:2,label:'冻结'},
                                         {value:5,label:'已审核'},{value:6,label:'弃审'},
                                         {value:3,label:'删除'}]}
                        /> */}
                         <ProFormDatePicker name='deliverdate' label='需求日期' width={200}
                            rules={[{required:true,message:'必填项' }]}
                         />
                   </Col>
              </Row>
              
                
               
              <EditableProTable
                     rowKey='rid'
                     name='editable'
                     actionRef={mtable2_ref}
                     editableFormRef={editorFormRef}
                     onChange={(data:any)=>setDataSource(data)}
                     columns={columns2}
                     recordCreatorProps={false}
                     search={false}
                     scroll={{y:400}}
                     editable = {{                       // defaultDom = {save,cancel,delete} 可以酌情添加和使用
                        actionRender: (row, config, defaultDom) => [
                          defaultDom.save,
                        //   defaultDom.cancel,
                        ],
                        type:'multiple'
                      }}
               />
                    
               </ProForm>
          </ProCard>
       </Modal>
    </>
};

export default App;